package com.linqi.freebie

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import com.linqi.freebie.ui.CustomerTypography
import com.linqi.freebie.ui.background
import com.linqi.freebie.ui.main.MainScreen
import com.linqi.freebie.ui.splash.SplashScreen
import org.jetbrains.compose.ui.tooling.preview.Preview

@Composable
@Preview
fun App() {
    MaterialTheme(typography = CustomerTypography()) {
        val snackbarHostState = remember { SnackbarHostState() }
        var showMainScreen by remember { mutableStateOf(false) }

        Scaffold(
            snackbarHost = { SnackbarHost(snackbarHostState) },
            containerColor = background
        ) { paddingValues ->
            Box(
                modifier = Modifier
                    .fillMaxSize()
                    .padding(paddingValues)
            ) {
                if (showMainScreen) {
                    MainScreen(snackbarHostState = snackbarHostState)
                } else {
                    SplashScreen(
                        onAnimationComplete = { showMainScreen = true },
                        word = "STƎAM",
                        logoText = "Freebie",
                        letterDelay = 200,
                        letterSpacing = 24.dp,  // 更大的字母间距
                        glowColor = Color.Yellow,
                        baseColor = Color.White,
                        logoColor = Color(0xFFFA8072),
                        holdDuration = 3500,
                        breathMinScale = 0.9f,
                        breathMaxScale = 1.1f
                    )
                }
            }
        }
    }
}
